package com.ycy;

import org.flowable.engine.*;
import org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration;
import org.junit.Before;

public class BaseNoListenerTest {

  protected ProcessEngine processEngine;

  protected ProcessEngineConfiguration cfg;

  // 获取Flowable服务 Get Flowable repositoryService
  protected RepositoryService repositoryService;

  // 获取Flowable服务 Get Flowable runtimeService
  protected RuntimeService runtimeService;

  // 获取taskService对象 Get the first task
  protected TaskService taskService;

  @Before
  public void before() {
    cfg = new StandaloneProcessEngineConfiguration()
//                .setJdbcUrl("jdbc:h2:mem:flowable;DB_CLOSE_DELAY=-1")
//                .setJdbcDriver("org.h2.Driver")
//                .setJdbcUsername("sa")
//            .setJdbcPassword("")
            .setJdbcUrl("jdbc:mysql://127.0.0.1:3306/flowablebp?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8")
//                .setJdbcUrl("jdbc:mysql://192.168.1.6:3306/flowablebp?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8")
            .setJdbcUsername("root")
            .setJdbcPassword("123456")
            .setJdbcDriver("com.mysql.jdbc.Driver")

            // 如果数据表不存在的时候，自动创建数据表
            .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);

    // 执行完成后，就可以开始创建我们的流程了
    processEngine = cfg.buildProcessEngine();

    // 获取Flowable服务 Get Flowable repositoryService
    repositoryService = processEngine.getRepositoryService();

    // 获取Flowable服务 Get Flowable runtimeService
    runtimeService = processEngine.getRuntimeService();

    // 获取taskService对象 Get the first task
    taskService = processEngine.getTaskService();

  }


}
